<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ include file="../../../attr.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=emulateIE7"/>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link rel="stylesheet" href="${ctx}/css/sapar.css"/>
    <link rel="stylesheet" type="text/css" href="${ctx}/css/common.css"/>
    <script type="text/javascript" src="${ctx}/js/jquery.js"></script>
    <script type="text/javascript" src="${ctx}/js/sapar.js"></script>
    <script type="text/javascript" src="${ctx}/js/WdatePicker.js"></script>
    <script type="text/javascript" src="${ctx}/assets/layer/layer.js"></script>
    <script type="text/javascript" src="${ctx}/js/mask.js"></script>


    <title>BD测试</title>

</head>
<body>
<div id="mask" class="mask"></div>
<div id="saper-container">
    <div class="wrap clearfix">
        <div class="content">
            <div class="subfiled clearfix">
                <h2>BD测试</h2>
            </div>
            <div class="subfiled-content">
                <form class="saper-form" id="dataForm">
                    <div class="kv-item clearfix">
                        <label>测试设备：</label>
                        <div class="kv-item-content">
                            <select id="equipId" name="ceshiEquipId" onChange="showSoft()">
                                <c:if test="${lstEquips != null}">

                                    <option value="">请选择</option>
                                    <c:forEach items="${lstEquips }" var="equip">
                                        <option value="${equip.equipId }">${equip.equipName }</option>
                                    </c:forEach>
                                </c:if>
                            </select>
                        </div>
                    </div>
                    <div class="kv-item clearfix">
                        <label>测试程序：</label>
                        <div class="kv-item-content">
                            <!-- <input type="texe" name="ceshiSoft" value="测试程序"> -->
                            <select id="seop" name="ceshiSoft">
                                <option>请选择</option>
                            </select>
                        </div>
                    </div>
                    <div class="kv-item clearfix">
                        <label>测试人：</label>
                        <div class="kv-item-content">
                            <input type="text" name="ceshirenTiaoma" placeholder="测试人" id="csr"
                                   onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')">
                        </div>
                    </div>
                    <div class="kv-item clearfix">
                        <label></label>
                        <div class="kv-item-content">
                            <a href="javascript:;" class="sapar-btn sapar-btn-recom query-btn">开始测试</a>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <div id="saper-ft"></div>
    </div>
</div>
<script type="text/javascript">
    function isNullOrEmpty(strVal) {
        strVal = strVal.replace(/(^\s*)|(\s*$)/g, "");
        if (strVal == '' || strVal == null || strVal == undefined) {
            return true;
        } else {
            return false;
        }
    }

    function showSoft() {
        var url = "${ctx}/soft/findCeshiChengxu.do?equipId=" + $("#equipId").val();
        $.ajax({
            type: "POST",
            url: url,
            data: "equipId",// 你的formid
            error: function (request) {
                layer.alert("网络故障，请稍后再试!");
            },
            success: function (data) {
                if (data.status == "true") {
                    $("#seop").empty();
                    var soft = data.lstSofts;
                    var str = '';
                    for (var i = 0; i < soft.length; i++) {
                        str += '<option id="seoption" value="' + soft[i].softId + '">' + soft[i].softName + '</option>';
                    }
                    $("#seop").append(str);
                }
            }
        });
    }


    $(function () {
        $(".query-btn").click(function () {
            var btn = true;
            var txt = $("#csr").val();
            $("select").each(function () {
                if ($(this).val() == '') {
                    btn = false;
                    alert("请选择");
                    return false;
                }
            });
            if (isNullOrEmpty(txt)) {
                btn = false;
                alert("请输入测试人");
                return false;
            }
            if (btn) {
                showMask();
                $.ajax({
                    type: "POST",
                    url: "${ctx}/miejun/startCeshi.do?testMan=" + txt,
                    data: $('#dataForm').serialize(),
                    error: function (request) {
                        layer.alert("网络故障，请稍后再试!");
                    },
                    success: function (data) {
                        $("#mask").hide();
                        if (data.state == "true") {
                            layer.alert("保存成功", function () {
                                window.location.href = "${ctx}/miejun/bd_ceshi.do";
                            });
                        } else {
                            alert(data.msg);
                        }

                        ;
                    }
                });
            }
        });
    });

</script>
</body>

</html>